import request from '@/utils/request'
// 封装数据接口
// import store from '@/store'
export const login = data => {
    return request({
        method: 'post',
        url: '/v1_0/authorizations',
        data
    })
}

export const getSmsCode = mobile => {
    return request({
        method: 'get',
        url: '/v1_0/sms/codes/' + mobile
    })
}
// 获取用户信息  不传递参数 
export const getUserInfo = () => {
    return request({
        url: '/v1_0/user',
        method: 'get',
        // 发送请求头数据
        // headers: {
        //     // 注意：该接口需要授权才能访问
        //     //       token的数据格式：Bearer token数据，
        //     // Bearer后面必须有一个空格
        //     Authorization: `Bearer ${store.state.user.token}`
        // }
        // 接口必须授权才能访问
    })
}
// 获取用户频道
export const getUserChannels = () => {
    return request({
        method: 'get',
        url: '/v1_0/user/channels'
    })
}
// 关注用户
export const addFollow = target => {
    return request({
        method: 'POST',
        url: '/v1_0/user/followings',
        data: {
            target
        }
    })
}
// 取消
export const deleteFollow = target => {
    return request({
        method: 'DELETE',
        url: `/v1_0/user/followings/${target}`,
        data: {
            target
        }
    })
}

// 获取个人资料
export const getUserProfile = () => {
    return request({
      method: 'GET',
      url: '/v1_0/user/profile'
    })
  }

// 更新信息资料
export const updateUserName = data => {
    return request({
        method: 'PATCH',
        url: '/v1_0/user/profile',
        data
    })
}

// 照片资料
export const updatePhotoImage = data => {
    return request({
        method: 'PATCH',
        url: '/v1_0/user/photo',
        data
    })
}